Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add createDeferredPromise #164

Merged
merged 5 commits into from
Jan 11, 2024
Merged

feat: Add createDeferredPromise #164

merged 5 commits into from
Jan 11, 2024

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Jan 10, 2024

A new function has been added for creating a deferred Promise. Deferred Promises can be useful for tracking async task, e.g. to prevent async tasks from overlapping, or to queue up async tasks. We use this pattern in multiple places in core and the extension.

A new function has been added for creating a deferred Promise. Deferred
Promises can be useful for tracking async task, e.g. to prevent async
tasks from overlapping, or to queue up async tasks. We use this pattern
in multiple places in core and the extension.
@Gudahtt Gudahtt requested a review from a team as a code owner January 10, 2024 21:29
expect(() => resolve()).not.toThrow();
});

describe('when suppressUnhandledRejection is set', () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried writing a test for when this was false, but there was no way to catch the unhandledRejection event. Apparently in the environment Jest runs tests in, the event always bubbles up to the parent process. Attaching an event handler for that event has no effect here. And there was no easy way to attach an event handler to the parent process, I think it'd require patching Jest or creating a custom test environment.

src/promise.ts Outdated Show resolved Hide resolved
This allows creating deferred Promises that return values
src/promise.ts Show resolved Hide resolved
@Gudahtt Gudahtt merged commit edcf2de into main Jan 11, 2024
17 checks passed
@Gudahtt Gudahtt deleted the add-create-deferred-promise branch January 11, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants